package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.AdminRole;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AdminRoleDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "角色id")
    private Integer roleId;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;


    public AdminRoleDTO() {}

    public AdminRoleDTO(AdminRole entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static AdminRoleDTO convert(AdminRole entity) {
        return new AdminRoleDTO(entity);
    }

    public static List<AdminRoleDTO> convertList(List<AdminRole> list) {
        List<AdminRoleDTO> resultList = new ArrayList<>();
        for (AdminRole entity : list) {
            resultList.add(new AdminRoleDTO(entity));
        }
        return resultList;
    }}
